#ifndef _PARAMETER_H_
#define _PARAMETER_H_

#include <stdint.h>
#include <stddef.h>
#include "mlib_config.h"


/*支持单个参数最大长度*/
#define SETTINGS_MAX_SIZE 		50 //必须小于50
/*管理参数个数*/
#define SETTINGS_MAX_NUM 		50

#define MG(X,Y) (((uint16_t)X<<8)+Y)

typedef enum{
	SETTINGS_SIGN_STRING = 0,
	SETTINGS_SOFT_VERSION,
	SETTINGS_DEVICE_SN,
	SETTINGS_DEVICE_TYPE,
	SETTINGS_HARDWARE_VERSION,
	SETTINGS_SYS_DATETIME,
	SETTINGS_UART_CONFIG,
	SETTINGS_AUTO_REBOOT_TIME,
	SETTINGS_REBOOT,
	SETTINGS_WIFI_SSID,
	SETTINGS_WIFI_PASSWORD,
	SETTINGS_CONNECT_MODE,
	SETTINGS_SERVER_IP,
	SETTINGS_SERVER_PORT,
	SETTINGS_COAP_SERVER_IP,
	SETTINGS_COAP_SERVER_PORT,
	SETTINGS_HEART_PERIOD,
	SETTINGS_PERIOD_UPLOAD1,
	SETTINGS_PERIOD_UPLOAD2,
	SETTINGS_ALARM_UPLOAD,
	SETTINGS_WAKEUP_RUN_TIME,
	SETTINGS_AREA_NUM,
	SETTINGS_DEVICE_NUM,
	SETTINGS_OTA_IP,
	SETTINGS_OTA_PORT,
	SETTINGS_OTA_FLAG,
	SETTINGS_OTA_FILE_NAME,
	SETTINGS_SALVE_DEVICE_TYPE,
	SETTINGS_METER_CNT1,
	SETTINGS_METER_CNT2,
	SETTINGS_LIMIT_CURRENT,
	SETTINGS_SWITCHOUT_PSW,
	SETTINGS_AMMETER_NUM,
	SETTINGS_AMMETER_INFO1,
	SETTINGS_AMMETER_INFO2,
	SETTINGS_AMMETER_INFO3,
	SETTINGS_AMMETER_INFO4,
}settings_param;

typedef uint32_t (*storage_wr_func)(uint32_t, uint8_t*, uint32_t);
/*系统参数*/
typedef struct {
	uint16_t len;
	uint8_t* nodePtr;
}SystemSettings;

typedef struct {
	uint8_t ini_flag;
	uint32_t start_addr;
	uint32_t stroage_size;
	storage_wr_func storage_write;
	storage_wr_func storage_read;
}settings_ini;


extern SystemSettings SystemSetting[SETTINGS_MAX_NUM];

void System_SettingsInit(storage_wr_func rf, storage_wr_func wf);
uint8_t System_SettingsRestore(void);
uint8_t System_SettingsSetSingle(uint8_t num,uint16_t len,uint8_t* data );
uint8_t System_SettingsSetMulti(uint8_t* data ,uint16_t num);
uint8_t System_SettingsSave(void);
void System_SettingsReport(void);




#endif // _PARAMETER_H_


